#!/bin/bash
# AI语音助手Web应用启动脚本

echo "=== AI语音助手Web应用启动脚本 ==="

# 检查Python版本
python3 --version
if [ $? -ne 0 ]; then
    echo "错误: 未找到Python3，请先安装Python3"
    exit 1
fi

# 检查依赖包
echo "检查依赖包..."
python3 -c "import flask, flask_socketio, requests, websocket, openai" 2>/dev/null
if [ $? -ne 0 ]; then
    echo "安装依赖包..."
    pip3 install flask flask-socketio requests websocket-client openai
fi

# 检查配置文件
if [ ! -f "config.json" ]; then
    echo "错误: 未找到config.json配置文件"
    exit 1
fi

# 检查测试音频文件
if [ ! -f "test_1.pcm" ]; then
    echo "警告: 未找到test_1.pcm测试音频文件"
    echo "某些功能可能无法正常工作"
fi

# 启动Web应用
echo "启动Web应用..."
echo "访问地址: http://localhost:5000"
echo "按Ctrl+C停止应用"
echo ""

python3 app.py
